package cn.nacos.naocses.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.PrintWriter;

/**
 * @author JavaLyl
 * @version V1.0.0
 * @ClassName SentinelWebConfig.java
 * @Description TODO
 * @createTime 2021-08-12 12:39:00
 */
@Configuration
public class SentinelWebConfig {
    @Bean
    public BlockExceptionHandler sentinelBlockExceptionHandler() {
        return ((request, response, e) -> {
            response.setStatus(429);
            PrintWriter out = response.getWriter();
            out.print("Oops,blocked by Sentinel:" + e.getClass().getSimpleName());
            out.flush();
            out.close();

            String s="<PAGE><SIZE>50,40</SIZE><TEXT x=\"8\" y=\"10\" w=\"1\" h=\"1\" r=\"0\">池州鲜达冷链供应链管理有限公司</TEXT><TEXT x=\"8\" y=\"45\" w=\"1\" h=\"1\" r=\"0\">品名:冷冻肩胛肉 </TEXT><TEXT x=\"210\" y=\"45\" w=\"1\" h=\"1\" r=\"0\">ID:65FDHGDF3R</TEXT><TEXT x=\"8\" y=\"80\" w=\"1\" h=\"1\" r=\"0\">入库日期:2021年8月13日</TEXT><TEXT x=\"200\" y=\"120\" w=\"1\" h=\"1\" r=\"0\">厂号：22222</TEXT><TEXT x=\"200\" y=\"160\" w=\"2\" h=\"1\" r=\"0\">净重KG</TEXT><TEXT x=\"190\" y=\"210\" w=\"3\" h=\"1\" r=\"0\">22.15 </TEXT><QR x=\"10\" y=\"120\" w=\"120\"  r=\"180\">https://www.baidu.com</QR><TEXT x=\"8\" y=\"260\" w=\"1\" h=\"1\" r=\"0\">青阳县庙前路168号  0566-5165678 </TEXT></PAGE>";
        });
    }
}
